package org.opencare.ndwc.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table ( name="t_event_type" )
public class EventType implements Serializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -8613857838175163409L;

	@Id @GeneratedValue(strategy=GenerationType.AUTO)
    private Long id;
	
	@Column(name = "name", unique = true)
	private String name;

	@Lob
	@Column(name = "description")
	private String description;
	
	@OneToMany(mappedBy = "hasEventType")
	private List<Event> events;
	  
	/**
	 * 
	 */
	public EventType() {
		// TODO Auto-generated constructor stub
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
    public List<Event> getEvents(){
		return this.events;		
	}
	
	public void setEvents(List<Event> events) {
        this.events = events;
    }

    public void addEvent(Event event) {
        if (this.events == null)
            this.events = new ArrayList<Event>();
        this.events.add(event);
    }	
}
